import time
from selenium import webdriver

def write_local_file(filename,text):
    with open(filename,"w",encoding="utf-8") as file:
        file.write(text)
        file.close()

def read_local_file(filename):
    with open(filename,"r",encoding="utf-8") as file:
        file.read(filename)
        file.close()

def fetch_website(url):
    driver = webdriver.Firefox()
    driver.get(url)
    return driver

def Vertify_Login(driver):
    """
    验证码的手动输入验证登录
    :param driver:
    :return:
    """
    # driver = fetch_website(url)
    driver.find_element_by_id("inputCount").send_keys("zl")
    driver.find_element_by_id("inputPassword").send_keys("123456")
    # 验证码
    code = input("请输入验证码:")
    driver.find_element_by_id("vertify_code").send_keys(code)
    driver.find_element_by_class_name('btn-success').click()

    return driver

def driver_wait(driver):
    time.sleep(10)
    driver.quit()


if __name__ == "__main__":
    url = "http://127.0.0.1:9000/user/login/"
    driver = fetch_website(url)
    driver_now = Vertify_Login(driver)
    driver_wait(driver_now)